package leecode.slidingWindow;

/**
 * @Classname
 * @Description TODO
 * @Date 2021/7/19 19:51
 * @Created by Alberthch
 *
 * 给定一个数组a，求他的最大连续三项和
 *
 * 由题意得，是一个固定滑动窗口的题目，窗口大小为3
 * 固定窗口的话。可以直接采用单指针right和窗口大小进行固定就可以了
 */
class FindThreeMaxSum {
    public static int findThreeMaxSum(int[] nums) {
        int len = nums.length;
        int res = 0;
        for (int r = 2;r < len; r++){
            res = Math.max(res,nums[r]+nums[r-1]+nums[r-2]);
        }
        return res;
    }

    public static void main(String[] args) {
        int[] nums = new int[]{-3,3,1,-3,2,4,7};
        System.out.println(findThreeMaxSum(nums));
    }

}
